package com.garlicts.excel.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ReflectUtil {

	public static Map<String, Field> getFieldMap(Object obj) {
		
		Map<String, Field> fieldMap = new HashMap<String, Field>();
		
		Class<? extends Object> clazz = obj.getClass();
		while(clazz != null && !clazz.getName().toLowerCase().equals("java.lang.object")) {
			Field[] declaredFields = clazz.getDeclaredFields();
			for(Field field : declaredFields) {
				fieldMap.put(field.getName(), field);
			}
			clazz = clazz.getSuperclass();
		}
		
		return fieldMap;
		
	}
	
}
